package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import beans.BeanLugares;
import utils.GeneradorXML;
import mapping.ElementoMapa;
import mapping.LugarInteres;

public final class lugaresinteres_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"error/errorpage.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      beans.BeanLugares mybean = null;
      synchronized (_jspx_page_context) {
        mybean = (beans.BeanLugares) _jspx_page_context.getAttribute("mybean", PageContext.PAGE_SCOPE);
        if (mybean == null){
          mybean = new beans.BeanLugares();
          _jspx_page_context.setAttribute("mybean", mybean, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\r\n");
      out.write("\r\n");

	mybean.conectar();
	String archivo = "lugares_default_" + session.getId() + ".xml";
	// devuelve TODOS los lugares para escribirlos en el XML
	List listLugaresDefault = mybean.getLugaresLatLngImgYTipo("-1");
	mybean.generaXMLLugares(archivo, listLugaresDefault);

      out.write("\r\n");
      out.write("<!-- VALIDADO!! :-D -->\r\n");
      out.write("\r\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n");
      out.write("\r\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n");
      out.write("  <head>\r\n");
      out.write("  \t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\r\n");
      out.write(" \t<link rel=\"stylesheet\" href=\"estilos/style.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>\r\n");
      out.write("  \t<link rel=\"stylesheet\" href=\"estilos/galeria.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>\r\n");
      out.write("    <script src =\"ajax/scriptaculous-js-1.8.1/lib/prototype.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("    <script src =\"ajax/scriptaculous-js-1.8.1/src/effects.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("    <script src =\"ajax/scriptaculous-js-1.8.1/src/controls.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("    <script src =\"ajax/scriptaculous-js-1.8.1/src/slider.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("   <script src=\"http://www.google.com/jsapi?key=ABQIAAAAW6ZkayH6hhgMyC2y6LQx8xQkRs_WW3LuT_BxsclnnM2SXBs4HxSp2Ukg-tY3gZU6rw7kePxNiNAS9Q\" type=\"text/javascript\"></script>\r\n");
      out.write("    <script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAW6ZkayH6hhgMyC2y6LQx8xTlOAjHTmgj9z0QOzdQFV7VnifGuxSJsOzr3eQromRGXbLCHJKjeEnNNw\" type=\"text/javascript\"></script> \r\n");
      out.write("    <script src=\"js/googlemaps.js\" type=\"text/javascript\" charset=\"utf-8\">\r\n");
      out.write("    </script>  \r\n");
      out.write("\t<script src=\"ajax/ajax_lugares.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("\t<script src=\"ajax/ajax_utils.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("\t<script src=\"ajax/ajax_login.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("\t<script src =\"js/visorgaleria.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("\t<script src=\"js/menu.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
      out.write("\t<title>Erasmushelp! - Lugares de interes</title>\r\n");
      out.write("\t<!--[if IE]> <link href=\"estilos/style_ie.css\" rel=\"stylesheet\" type=\"text/css\"> <![endif]-->\r\n");
      out.write("\t\r\n");
      out.write("  </head>\r\n");
      out.write(" <body onload=\"precargaBasica('");
      out.print(archivo);
      out.write("');inicializaLugaresInteres('");
      out.print(archivo);
      out.write("');\" onunload=\"GUnload()\">\r\n");
      out.write(" <!--  onunload=\"destruyeArchivo('");
      out.print(archivo);
      out.write("');GUnload()\">-->\r\n");
      out.write("\t\r\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "hidden.jsp", out, false);
      out.write("\r\n");
      out.write("\t<div id='page_wrapper'>\r\n");
      out.write("\t\r\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "cabecera.jsp", out, false);
      out.write("\r\n");
      out.write("\t\r\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "menu.jsp", out, false);
      out.write("\r\n");
      out.write("\t\r\n");
      out.write("\t<div id='content_wrapper'>\r\n");
      out.write("\t\r\n");
      out.write("\t<div class='spacer'></div> \r\n");
      out.write("\t\r\n");
      out.write("\t<div id='contenido'>\r\n");
      out.write("\t\t<form id =\"form_lugares\" action=\"lugaresinteres.jsp\" method=\"get\" onsubmit=\"return false\"> \r\n");
      out.write("\t\t\t<!-- guardamos el archivo xml en un campo oculto para poder trabajar con �l en procesabusquedalugares\r\n");
      out.write("\t\t\tya que el id de la sesion cambia en cada pagina, por tanto, el archivo con el q se trabaja en procesa es distinto a este-->\r\n");
      out.write("\t\t\t<fieldset>\r\n");
      out.write("\t\t\t<legend>B&uacute;squeda de lugar</legend>\r\n");
      out.write("\t\t\t<div>\r\n");
      out.write("\t\t\t\t<input type=\"hidden\" id=\"archivo\" name=\"archivo\" value=\"");
      out.print( archivo);
      out.write("\"/>\r\n");
      out.write("\t\t\t</div>\r\n");
      out.write("\t\t\t<div id=\"wrapper_formlugares\">\r\n");
      out.write("\t\t\t\t<div id=\"formlugar\">\r\n");
      out.write("\t\t\t\t\t<label for=\"nomlugar\">Nombre</label>\r\n");
      out.write("\t\t\t\t\t<input type=\"text\" id=\"nomlugar\" name=\"nomlugar\" title=\"Escribe el nombre de un lugar\" size=\"30\" maxlength=\"50\"/>\r\n");
      out.write("\t\t\t\t</div>\r\n");
      out.write("\t\t\t\t\r\n");
      out.write("\t\t\t\t<div id=\"btnBusquedaLugar\">\r\n");
      out.write("\t\t\t\t\t<button id=\"btnbuscarlugar\" class=\"mybtn\" onmouseover=\"goLite(this)\" onmouseout=\"goDim(this)\">Buscar</button>\r\n");
      out.write("\t\t\t\t</div>\r\n");
      out.write("\t\t\t</div><!--  fin id=\"wrapper_formlugares\" -->\r\n");
      out.write("\t\t\r\n");
      out.write("\t\t\t<div style=\"float:left\">\r\n");
      out.write("\t\t\t\t<label for=\"tipo_lista\">Tipo</label><br/>\r\n");
      out.write("\t\t\t\t\t<select id=\"tipo_lista\" name=\"tipo\" multiple=\"multiple\" size = \"5\" title=\"Selecciona el tipo de lugar\">\r\n");
      out.write("\t\t\t\t\t");

						mybean.generaFicheroXMLTipoLugares();
						List listaTipoLugares = mybean.getTipoLugares();
						Iterator it = listaTipoLugares.iterator();
						while(it.hasNext()){
							//El metodo Split de String separa una cadena en varias partes 
							//teniendo como delimitador la expresion regular que se pase como 
							//parametro
							String [] valorTipo = ((String) it.next()).split(",");
							
      out.write("\r\n");
      out.write("\t\t\t\t\t\t\t<option value = \"");
      out.print(valorTipo[0]);
      out.write("\"  onclick=\"habilitar('btnBorraSeleccion'); Markers('");
      out.print(valorTipo[1]);
      out.write("'); cierraGlobo()\">");
      out.print(valorTipo[1]);
      out.write("</option>\r\n");
      out.write("\t\t\t\t\t\t");

						}//fin while
						mybean.desconectar();
					
      out.write("\r\n");
      out.write("\t\t            </select><br/>\r\n");
      out.write("\t\t           <button id=\"btnBorraSeleccion\" class=\"mybtn\" onmouseover=\"goLite(this)\" onmouseout=\"goDim(this)\">Deseleccionar tipos</button>\r\n");
      out.write("\t\t     </div><!-- fin <div style=\"float:left\"> -->\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\t<div style=\"clear:both\">\r\n");
      out.write("\t\t\t\t<!-- Obtencion del id_usuario : lo guardamos en un input -->\r\n");
      out.write("\t\t\t\t<input type=\"hidden\" id =\"iniciotupla\"  name=\"iniciotupla\" size=\"2\" readonly=\"readonly\" value=\"0\"/>\r\n");
      out.write("\t\t\t</div>\r\n");
      out.write("\t\t\t</fieldset>\r\n");
      out.write("\t\t</form>\t\r\n");
      out.write("\t\t<div class='spacer'></div>\r\n");
      out.write("\t\t<div id = \"btnplegarmapa\">\r\n");
      out.write("\t\t\t<button class=\"mybtn\" onclick=\"ocultaOMuestraElemento('celdaDivMapa','BlindUp')\">Ocultar&frasl;Mostrar</button>\r\n");
      out.write("\t\t</div>\r\n");
      out.write("\t\t<div id=\"celdaDivMapa\" class=\"mapuser\">\r\n");
      out.write("\t\t\t<div id=\"map\" style=\"height:400px; width:820px;\"></div>\r\n");
      out.write("\t\t</div>\r\n");
      out.write("\t\t<div class='spacer'></div>\r\n");
      out.write("\t\t <div id=\"res_agregado\"></div>\r\n");
      out.write("\t\t \r\n");
      out.write("\t\t<div id=\"lista_lugares\"></div>\r\n");
      out.write("\t\t<div class='spacer'></div>\r\n");
      out.write("\t</div><!--fin <div id='contenido'>-->\r\n");
      out.write("</div>\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "pie.html", out, false);
      out.write("\r\n");
      out.write("</div>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
      out.write("\r\n");
      out.write("\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
